{% extends "base.html" %}

{% block title %}{% if market %}编辑超市{% else %}添加超市{% endif %} - 妙趣拾光锦盒管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12 mb-4">
        <h2 class="border-bottom pb-2">
            <i class="fas {% if market %}fa-edit{% else %}fa-plus-circle{% endif %} me-2"></i>
            {% if market %}编辑超市{% else %}添加超市{% endif %}
        </h2>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card shadow-sm">
            <div class="card-body">
                <form method="POST" enctype="multipart/form-data">
                    <div class="mb-3">
                        <label for="name" class="form-label">超市名称 <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="name" name="name" required value="{{ market.name if market else '' }}">
                    </div>
                    
                    <div class="mb-3">
                        <label for="address" class="form-label">地址</label>
                        <input type="text" class="form-control" id="address" name="address" value="{{ market.address if market else '' }}">
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="phone" class="form-label">联系电话</label>
                                <input type="text" class="form-control" id="phone" name="phone" value="{{ market.phone if market else '' }}">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="business_hours" class="form-label">营业时间</label>
                                <input type="text" class="form-control" id="business_hours" name="business_hours" value="{{ market.business_hours if market else '' }}" placeholder="例如: 09:00-22:00">
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="longitude" class="form-label">经度</label>
                                <input type="text" class="form-control" id="longitude" name="longitude" value="{{ market.longitude if market else '' }}">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="latitude" class="form-label">纬度</label>
                                <input type="text" class="form-control" id="latitude" name="latitude" value="{{ market.latitude if market else '' }}">
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="description" class="form-label">超市描述</label>
                        <textarea class="form-control" id="description" name="description" rows="4">{{ market.description if market else '' }}</textarea>
                    </div>
                    
                    <div class="mb-3">
                        <label for="image_url" class="form-label">超市图片URL</label>
                        <input type="text" class="form-control" id="image_url" name="image_url" value="{{ market.image_url if market else '' }}">
                        <small class="form-text text-muted">输入超市图片的网络地址</small>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="rating" class="form-label">评分(1-5)</label>
                                <input type="number" step="0.1" min="1" max="5" class="form-control" id="rating" name="rating" value="{{ market.rating if market else '5.0' }}">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="status" class="form-label">状态</label>
                                <select class="form-select" id="status" name="status">
                                    <option value="1" {% if market and market.status == 1 %}selected{% endif %}>营业中</option>
                                    <option value="0" {% if market and market.status == 0 %}selected{% endif %}>暂停营业</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="d-grid gap-2 d-md-flex justify-content-md-end mt-4">
                        <a href="{{ url_for('supermarket.list') }}" class="btn btn-secondary me-md-2">
                            <i class="fas fa-times me-1"></i>取消
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save me-1"></i>保存
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card shadow-sm">
            <div class="card-header bg-light">
                <h5 class="mb-0"><i class="fas fa-info-circle me-2"></i>提示信息</h5>
            </div>
            <div class="card-body">
                <p><strong>超市名称：</strong>必填，请输入具有特点的名称</p>
                <p><strong>地址：</strong>超市的详细地址，方便用户查找</p>
                <p><strong>联系电话：</strong>客户服务或门店电话</p>
                <p><strong>营业时间：</strong>如：周一至周五 09:00-22:00，周末 10:00-22:00</p>
                <p><strong>经纬度：</strong>超市的地理位置坐标，用于地图定位</p>
                <p><strong>超市描述：</strong>可以添加超市的简介、特色等信息</p>
                <p><strong>超市图片URL：</strong>可以添加超市的门面图片或标志性图片</p>
                <p><strong>评分：</strong>超市的评分，范围1-5分</p>
                <p><strong>状态：</strong>选择超市当前是否营业中</p>
            </div>
        </div>
    </div>
</div>
{% endblock %}
